#include <stdio.h>

int main()
{
    FILE* fp = fopen("work1.txt", "w"); 
    if (NULL == fp)
    {
        perror("fopen");
        return -1;
    }
    int txt1[] = {1,2,3,4,5};
    fwrite(txt1, sizeof(txt1[0]), 5, fp);//数据流, 每个数据的字节, 数据个数, 文件流
    fclose(fp); 
    

    FILE* fp2 = fopen("work1.txt", "r"); 
    if (NULL == fp2)
    {
        perror("fopen");
        return -1;
    }
    fseek(fp2, sizeof(int)*2, SEEK_SET);//偏移两个int字节大小
    int txt2[10] = {0};
    int ret_fread = fread(txt2, sizeof(txt2[0]), 2, fp2);//数据流, 每个数据的字节, 数据个数, 文件流
    for (int i=0; i<10; i++)
    {
        printf("txt2[%d]:%d\n", i, txt2[i]);
    }
    printf("ret_fread: %d\n", ret_fread);
    fclose(fp2); 
    
    //fseek 偏移流位置指示器
    return 0;
}
